import { createRouter, createWebHistory } from "vue-router";
// 创建路由实例
const router = createRouter({
  history: createWebHistory(),
  routes: [
    // 在这个数组中进行路由规则的详细配置
    {
      path: "/",
      redirect: "/login",
    },
    {
      // 登录页
      path: "/login",
      component: () => import("@/views/Login/index.vue"),
    },
    {
      //布局页
      path: "/",
      component: () => import("@/Layout/index.vue"),
      // 路由嵌套
      children: [
        {
          path: "/user",
          component: () => import("@/views/User/index.vue"),
          meta: {
            title: "用户管理",
            icon: "user",
          },
        },
        {
          path: "/system",
          meta: {
            title: "系统管理",
            icon: "system",
          },
          children: [
            {
              // 平台账号管理
              path: "/system/account",
              component: () => import("@/views/System/Account/index.vue"),
              meta: {
                title: "平台账号管理",
              },
            },
            {
              // 字典设置
              path: "/system/dictionary",
              component: () => import("@/views/System/Dictionary/index.vue"),
              meta: {
                title: "字典设置",
              },
            },
            {
              // 参数设置
              path: "/system/parameter",
              component: () => import("@/views/System/Parameter/index.vue"),
              meta: {
                title: "参数设置",
              },
            },
          ],
        },
      ],
      // 用户管理
    },
    {
      // 401 错误页
      path: "/401",
      component: () => import("@/views/Error/401.vue"),
    },
    {
      // 404 错误页
      path: "/:pathMatch(.*)*",
      component: () => import("@/views/Error/404.vue"),
    },
  ],
});
export default router;
